package com.an.homework;

import java.util.Scanner;

public class HomeWork_8 {
    public static void main(String[] args) {
        AA aa = new AA();
       aa.f();
        //异常处理
//        boolean bool=true;
//        Scanner scanner = new Scanner(System.in);
//        do{
//            System.out.println("请输入一个整数");
//            String x=scanner.next();
//            try{
//                int num=Integer.parseInt(x);
//                bool=false;
//            }
//            catch (Exception e){
//                System.out.println("请输入整数");
//            }
//        }while(bool);

    }
}
//
class AA{

    public void f(){
        boolean bool=true;
        int num=0;
        Scanner scanner = new Scanner(System.in);
        do{
            System.out.println("请输入整数");
        String x=scanner.next();
            try{
          num=Integer.parseInt(x);
                bool=false;
     }
     catch (Exception e){
     }
        }while(bool);
        System.out.println("num="+num);

    }
}
